package com.fire.control.system.module.notice.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.fire.control.system.dto.UserDTO;
import com.fire.control.system.dto.app.AppNoticeVo;
import com.fire.control.system.module.notice.dao.NoticeMapper;
import com.fire.control.system.module.notice.service.AppNoticeService;
import com.fire.control.system.statics.ResponseMessage;
import com.fire.control.system.support.protocol.app.AppRequestProtocol;
import com.fire.control.system.support.protocol.comman.ProtocolSelector;
import com.fire.control.system.support.protocol.comman.ResponseProtocol;
import com.fire.control.system.support.util.XdaoDate;

/**
 * 
 * @ClassName:  AppNoticeServiceImpl
 * @Description:  App首页服务层接口具体实现
 * @author:  xiechengguang
 * @date:  2017年6月8日 上午9:51:08
 *
 */
@Service
public class AppNoticeServiceImpl implements AppNoticeService {
	@Autowired private ProtocolSelector protocolSelector;
	@Autowired private NoticeMapper noticeMapper;
	
	
	/**
	 * <p>Author: xiechengguang</p> 
	 * <p>Title: noticeList</p> 
	 * <p>Description: </p> 
	 * @param requestProtocol
	 * @param u
	 * @return 
	 * @see com.fire.control.system.module.notice.service.AppNoticeService#noticeList(com.fire.control.system.support.protocol.app.AppRequestProtocol, com.fire.control.system.dto.UserDTO)
	 */
	@Override
	public ResponseProtocol noticeList(AppRequestProtocol requestProtocol,UserDTO u) {
		ResponseProtocol response = protocolSelector.choose(requestProtocol);
		// 通知列表
		List<AppNoticeVo> notices = noticeMapper.getInValidTime(u.getUserId());
		if(notices != null && !notices.isEmpty()) {
			ResponseMessage.CODE_200.messageToProtocol(response);
			response.setDate(new XdaoDate());
			response.setData(notices);
			return response;
		}
		ResponseMessage.CODE_204.messageToProtocol(response);
		response.setDate(new XdaoDate());
		return response;
	}
	
	

}
